home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / gag / WaveBench.lha / WaveBench / cop.asm < prev    next >
Assembly Source File  |  1987-11-15  |  5KB  |  166 lines

  1. ;
  2. ;   cop.asm, the copper list mangler for "Wavebench".  Written 15-Oct-87
  3. ;   by Bryce Nesbitt.  No copyright claimed.
  4. ;
  5. ;   This version should assemble under Metacomco V11.0 or the Manx 3.4b
  6. ;   assembler.
  7. ;
  8. ;   Will mangle Intuition's private View every other frame until
  9. ;   either the proper signal bits have been changed or something
  10. ;   strange happens.
  11. ;
  12. ;   This program is "dirty", and will not work on upgraded version of
  13. ;   the graphics copprocessor.
  14. ;
  15.     NOLIST
  16.     INCLUDE "exec/types.i"
  17.     INCLUDE "graphics/gfx.i"
  18.     INCLUDE "graphics/copper.i"
  19.     INCLUDE "graphics/view.i"
  20. jsrlib    MACRO
  21.     jsr  _LVO\1(a6)
  22.     XREF _LVO\1
  23.     ENDM
  24.     LIST
  25.  
  26. ;---------------Size of animation table must be here due to Aztec assembler------
  27. ;---------------stupidity.------
  28. maxtable    equ    18  ;Size of table
  29. maxwinkle    equ    18  ;Table offset for start the wave (same as above)
  30. ;---------------
  31.  
  32. rgfxbase    EQUR    a4
  33. rview        EQUR    a5  ;register copy of View
  34. rwsignals    EQUR    d5
  35. inscounter    EQUR    d6
  36. startwinkle    EQUR    d7
  37.  
  38.         XDEF    _manglecop
  39. _manglecop    movem.l d0-d7/a0-a7,-(a7)
  40.         move.l    16*4+4(a7),rwsignals       ;wsignals
  41.         move.l    16*4+8(a7),rview       ;MyViewP
  42.         move.l    16*4+12(a7),rgfxbase        ;GfxBase
  43.  
  44. resetwinkle    moveq.l #maxtable+2,startwinkle
  45. keeponwavin    subq.w    #2,startwinkle
  46.         bmi.s    resetwinkle
  47.  
  48.         move.l    rgfxbase,a6    ;get graphics.library
  49.         jsrlib    WaitTOF
  50.         jsrlib    WaitTOF
  51.  
  52.         move.l    4,a6        ;get exec.library
  53. ; Using the Forbid() library call is the preferred way of doing this...
  54. ; Never use one of those silly macros for Forbid... that will cause
  55. ; problems with stuff planned for the future.
  56. ;        jsrlib    Forbid        ;we ain't 'fraid 'o 'other tasks
  57.  
  58.         move.l    v_LOFCprList(rview),d1
  59.         beq.s    noLOF
  60.         move.l    startwinkle,d0
  61.         bsr.s    Animatecprlst
  62. noLOF        move.l    v_SHFCprList(rview),d1    ;for interlaced screens only
  63.         beq.s    noSOF
  64.         move.l    startwinkle,d0
  65.         bsr.s    Animatecprlst
  66. noSOF           ;jsrlib    Permit
  67.  
  68.         moveq.l #0,d0
  69.         moveq.l #0,d1
  70.         jsrlib    SetSignal
  71.         and.l    rwsignals,d0
  72.         beq.s    keeponwavin
  73.  
  74. ;-------------- We're outta here! --------------
  75.  
  76. signalfound    movem.l (a7)+,d0-d7/a0-a7
  77.         moveq.l #0,d0
  78.         rts
  79.  
  80. ;-----------------------------------------------
  81. ; Animatecprlst(cprlist,cell),exec
  82. ;        d1    d0    a6
  83. ;
  84. ;   uses inscounter
  85. ;   Call while Forbid()ed!
  86. ;   Animate the copper list starting at the specified cell.  Typically
  87. ;   this will be called twice on interlace displays, once for each
  88. ;   long and short frame cprlist.
  89. ;
  90. Animatecprlst    move.l    d1,a0
  91.         move.w    crl_MaxCount(a0),inscounter
  92.         beq.s    bogus
  93.         move.l    crl_start(a0),d1
  94.         beq.s    bogus
  95.         btst.l    #1,d1
  96.         bne.s    bogus
  97.         ;Could call TypeOfMem() here...
  98.         move.l    d1,a0
  99.  
  100. ;This the place that animates the actual list.    There are two components
  101. ;that we need to worry about.  First comes "move to diwstop".  This register
  102. ;defines the physical right edge of the display.  Since we are about to play
  103. ;with the horizontal scroll registers this will need to be expanded.  (else
  104. ;the wave would get clipped on the left and the right).  Only the diwstop
  105. ;nearest the scroll register moves will be affected, and then only if there
  106. ;actually are scroll register moves.
  107.  
  108. ;Kludge to make it a little bit faster
  109.         subq.l    #2,a0
  110. finddiwstope    addq.l    #2,a0
  111.         cmp.w    #$0090,(a0)+        ;compare with "move to diwstop"
  112.         dbeq    inscounter,finddiwstope ;branch UNTIL equal
  113.         bne.s    endoflist1
  114.         move.l    a0,a1
  115.  
  116. ;Scan for first bplcon1 move and keep track of the most recent move to
  117. ;diwstop
  118. finddiwstop    addq.l    #2,a0
  119.         move.w    (a0)+,d1        ;get the copper instruction
  120.         cmpi.w    #$0090,d1        ;compare with "move to diwstop"
  121.         bne.s    notdiwstop
  122.         move.l    a0,a1            ;save pointer for later, a1
  123. notdiwstop    cmp.w    #$0102,d1        ;compare with "move to bplcon1"
  124.         dbeq    inscounter,finddiwstop    ;branch UNTIL equal
  125.         bne.s    endoflist1
  126.  
  127. ; We have found the first move to bplcon1.  Any more that come along will
  128. ; be assumed to have come from our user copperlist. (The first one is
  129. ; left alone)
  130.  
  131. findbplcon1e    addq.l    #2,a0
  132.         cmpi.w    #$0102,(a0)+        ;compare with "move to bplcon1"
  133.         dbeq    inscounter,findbplcon1e
  134.         bne.s    endoflist2
  135.  
  136.         or.w    #$00ff,(a1)        ;make screen wider
  137.         move.w    table(pc,d0.w),(a0)
  138.         subq.w    #2,d0
  139.         bpl.s    findbplcon1
  140.         moveq.l #maxtable,d0
  141.  
  142. ; We have found the second move to bplcon1.  Any more that come along will
  143. ; be assumed to have come from our user copperlist.
  144.  
  145. findbplcon1    addq.l    #2,a0
  146.         cmpi.w    #$0102,(a0)+        ;compare with "move to bplcon1"
  147.         dbeq    inscounter,findbplcon1
  148.         bne.s    endoflist2
  149.  
  150.         move.w    table(pc,d0.w),(a0)
  151.         subq.w    #2,d0
  152.         bpl.s    findbplcon1
  153.         moveq.l #maxtable,d0
  154.         bra.s    findbplcon1
  155.  
  156. ;---------------Animation data table ----------
  157. table        dc.w    $00,$11,$22,$33,$33,$33,$22,$11,$00,$00,$ff
  158. ;If you play with this, be sure to update size equates above!!
  159. ;---------------
  160. bogus
  161. endoflist0
  162. endoflist1
  163. endoflist2    rts
  164.  
  165.         END
  166.